<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
	<title>已办任务</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			
		});
		function page(n,s){
        	location = '${ctx}/act/task/historic/?pageNo='+n+'&pageSize='+s;
        }
		
		function doSearch(){
			$("#searchForm").submit();
		}
	</script>
</head>
<body>

        <div class="boxcontent clearfix" >
		<div class="content clearfix">
	    <form:form id="searchForm" modelAttribute="act" action="${ctx}/act/task/historic/" method="get">
	    <div class="search-bar">
				<input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
				<input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
				<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}" callback="page();"/>
				<ul class="clearfix">
					<li>
						<span>流程名称：</span>
						<form:input path="actProcDefName" htmlEscape="false" class="form-control"/>
					</li>
					</li>
						<li>
					    <span>接收时间开始：</span>
					    <input id="beginDate" name="beginDate" type="text" readonly="readonly" maxlength="20"
						class="form-control Wdate"
						value="<fmt:formatDate value="${act.beginDate}" pattern="yyyy-MM-dd"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" />
					</li>
					<li>
					    <span>到</span>
					    <input id="endDate" name="endDate" type="text" readonly="readonly" maxlength="20"
						class="form-control Wdate"
						value="<fmt:formatDate value="${act.endDate}" pattern="yyyy-MM-dd"/>"
						onclick="WdatePicker({dateFmt:'yyyy-MM-dd'});" />
					</li>
					</ul>
					
					<div id="btn_search" class="search-btn" onclick="doSearch();">查询</div>
				    <script type="text/javascript">
				     $(function(){
					    $(".search-bar ul li").each(function(){
						var spanWidth = $(this).find("span").width();
						$(this).find(".form-control").width(230-20-spanWidth);	
						$(this).children(".input-append").find(".required").width(230-20-36+1-spanWidth);	
						var barHeight = $(".search-bar").height();
						$(".search-btn").css("line-height", barHeight+"px");
					});
				})
				</script>
				</div>
	</form:form>
	
	<div class="btns" style="float: left;border-right: 0px;border-left:0px;">
		<button type="button" class="btn-custom" onclick="shenpi()">审批信息</button>
		<button type="button" class="btn-custom" onclick="genzong();">当前环节</button>
	</div>
	<script>
		function shenpi(){
			var checked=$("#contentTable").find("tbody>tr").find("input[type=checkbox]:checked");
			if(checked.length==0){
				top.$.jBox.tip("请选择一条数据");
				return false;
			}
			if(checked.length>1){
				top.$.jBox.tip("不能同时选择多条数据操作");
				return false;
			}
			
			var url=$(checked[0]).attr("data-url");
			var id=$(checked[0]).attr("data-id");
			
			opencreateWindow(url+"?id="+id,"审批信息",1200,600,"10px")
		}
		
		function genzong(){
			
			var checked=$("#contentTable").find("tbody>tr").find("input[type=checkbox]:checked");
			if(checked.length==0){
				top.$.jBox.tip("请选择一条数据");
				return false;
			}
			if(checked.length>1){
				top.$.jBox.tip("不能同时选择多条数据操作");
				return false;
			}
			
			var urlhead=$(checked[0]).attr("data-urlhead");
			var processDefinitionId=$(checked[0]).attr("data-processDefinitionId");
			var processInstanceId=$(checked[0]).attr("data-processInstanceId");
			
			window.location.target="_blank"
		    window.open(urlhead+"/act/diagram-viewer?processDefinitionId="+processDefinitionId+"&processInstanceId="+processInstanceId);
			//window.location.href=
		}
		
		
	</script>
	
	<sys:message content="${message}"/>
	<table id="contentTable" class="table table-striped table-bordered table-condensed">
		<thead>
			<tr>
				<th><input type="checkbox" disabled/></th>
				<th>标题</th>
				<th>申请人</th>
				<th>申请部门</th>
				<th>当前环节</th><%--
				<th>任务内容</th> --%>
				<th>流程名称</th>
				<th>上一步处理人</th>
				<th>流程版本</th>
				<th>接收时间</th>
				<th>完成时间</th>
				<!--<th>操作</th>-->
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${page.list}" var="act">
				<c:set var="task" value="${act.histTask}" />
				<c:set var="vars" value="${act.vars}" />
				<c:set var="procDef" value="${act.procDef}" /><%--
				<c:set var="procExecUrl" value="${act.procExecUrl}" /> --%>
				<c:set var="status" value="${act.status}" />
				<tr>
					<td>
						<input type="checkbox" data-url="${act.formUrl}" data-id="${act.businessId}" data-urlhead="${pageContext.request.contextPath}" data-processDefinitionId="${task.processDefinitionId}" data-processInstanceId="${task.processInstanceId}"/>
					</td>
					<td>
						${fns:abbr(not empty vars.map.title ? vars.map.title : task.id, 60)}
					</td>
					<td>
						${act.vars.map.applyUserName} 
					</td>
					<td>
						${act.vars.map.applyOrgName} 
					</td>
					<td>
						${task.name}
						<%--
						<a target="_blank" href="${ctx}/act/task/trace/photo/${task.processDefinitionId}/${task.executionId}">${task.name}</a>
						<a target="_blank" href="${ctx}/act/task/trace/info/${task.processInstanceId}">${task.name}</a> --%>
					</td><%--
					<td>${task.description}</td> --%>
					<td>${procDef.name}</td>
					<td>${act.previousAssigneeName}</td>
					<td><b title='流程版本号'>V: ${procDef.version}</b></td>
					<td><fmt:formatDate value="${task.startTime}" type="both"/></td>
					<td><fmt:formatDate value="${task.endTime}" type="both"/></td>
					<!-- <td>
						<a href="${ctx}/act/task/form?taskId=${task.id}&taskName=${fns:urlEncode(task.name)}&taskDefKey=${task.taskDefinitionKey}&procInsId=${task.processInstanceId}&procDefId=${task.processDefinitionId}&status=${status}">详情</a>
					</td>  -->
				</tr>
			</c:forEach>
		</tbody>
	</table>
	<div class="pagination">${page}</div>
	
	<script type="text/javascript">
		/* add for lgx
		url :url /allAsset/dialogCategoryIndex
		title:标题
		width：宽度
		height：高度
		top：窗口离顶部的距离,可以是百分比或像素(如 100px)
		use:打开新增窗口
		 */
		function opencreateWindow(url, title, width, height, topValue) {
			url = "iframe:" + "${ctx}/" + url;
			topValue = (topValue == '' ? '10%' : '10px');
			top.$.jBox.open(url, title, width, height, {
				persistent : true,
				top : topValue,
				buttons : {},
				submit : function(v, h, f) {
					/*  点击窗口按钮后的回调函数，返回true时表示关闭窗口，参数有三个，
					 v表示所点的按钮的返回值，
					 h表示窗口内容的jQuery对象，
					 f表示窗口内容里的form表单键值
					 */
				},
				closed : function() {
					/* 窗口关闭后执行的函数 */
					var istrue = $('#closedwindow',
							window.parent.parent.document).val();
					if (istrue == "true") {
						//alert(111);
						//window.location.reload();
						$('#closedwindow', window.parent.parent.document).val(
								"false");
						$("#btn_search").click();
					}
				}
			});
		}
	</script>
	</div>
    </div>
</body>


</html>
